package com.fzkj.thread.async;

import java.util.Timer;

/**
 * 测试变量同步
 */
public class Test {

    public static Timer timer = null;

    public static void startTimer(Timer ti){
        timer.schedule(new MyTimerTask(ti), 1000);
    }

    public static void main(String[] args) throws Exception{
        timer = new Timer();
        startTimer(timer);
        Thread.sleep(2000);
        if (timer != null){
            System.out.println("timer已经启动。。。");
            return;
        }
        startTimer(timer);
//        timer.schedule(new MyTimerTask(timer), 10000);
//        Thread.sleep(5000);
//        timer.cancel();
//        timer.schedule(new MyTimerTask(timer), 2000);
//        timer.schedule(new MyTimerTask(timer), 3000);

    }

}
